﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SARUserControls
{
    /// <summary>
    /// Interaction logic for SAR_BigButton.xaml
    /// </summary>
    public partial class SAR_BigButton : UserControl
    {
        public SAR_BigButton()
        {
            InitializeComponent();
        }

        private string windowsTxt;

        //WindowsText属性，按钮显示文本
        public string SARWindowsText
        {
            get
            {
                windowsTxt = this.TextFiled.Text;
                return windowsTxt;
            }
            set
            {
                windowsTxt = value;
                this.TextFiled.Text = windowsTxt;
            }
        }

        //定义事件
        public event MouseButtonEventHandler SARBigBtnClick;

        private void bigBtn_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (!isEnabled)
            {
                return;
            }

            this.TextFiled.Margin = new Thickness(62, 8.120, 0, 0);

            if (SARBigBtnClick != null)
            {
                SARBigBtnClick.Invoke(this, e);
            }
        }

        private bool isEnabled = true;
        public bool SARIsEnabled
        {
            set
            {
                isEnabled = value;
                if (isEnabled)
                {
                    this.Opacity = 1;
                }
                else
                {
                    this.Opacity = 0.5;
                }
            }
            get
            {
                return isEnabled;
            }
        }

        private void bigBtn_MouseLeave(object sender, MouseEventArgs e)
        {
            if (!isEnabled)
            {
                return;
            }

            this.TextFiled.Margin = new Thickness(61, 7.120, 0, 0);
        }

        private void bigBtn_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (!isEnabled)
            {
                return;
            }

            this.TextFiled.Margin = new Thickness(61, 7.120, 0, 0);
        }
    }
}
